/*
 * Company  : Datalogic S.p.A.
 * Title    : LIBRARY USER FUNCTIONS
 * Filename : LIBRARY.H
 * System   : Keil-Frankling C-Language Compiler
 * MemoryMod: large
 * Notes    :
 */

/************************ GENERAL FUNCTIONS ************************/
#include "typedef.inc"

extern void rdytsk( unsigned char id_tsk );
extern void slptsk( unsigned char id_tsk );
extern void dlytsk( unsigned char id_tsk, unsigned int delay_time );
extern unsigned char rqstsk( unsigned char priority, void( code *pt_tsk )( void ) );
extern unsigned char statsk( unsigned char id_tsk );

extern unsigned char rqtim( void( code *ext_endtim_proc )( void ) );
extern void wrtim( unsigned char id_timer, unsigned char stat_req, unsigned int countval );
extern unsigned char rdtimst( unsigned char id_timer );
extern unsigned int rdtimc( unsigned char id_timer );

extern void dec_hreqst( struct dec_hreqst_message dec_hr_msg );
extern void dec_habort( void );
extern void dec_hcnfg0( unsigned char proc_name, void( *relatefunct )( void ) );

extern void rx_hreqst( struct rtx_hreqst_message rx_hr_msg );        /* hdlcom0X.obj */
extern void rx1_hreqst( struct rtx1_hreqst_message rx_hr_msg );      /* hdlcom1X.obj */
extern void rx_habort( void );

extern void tx_hreqst( struct rtx_hreqst_message tx_hr_msg );        /* hdlcom0X.obj */
extern void tx1_hreqst( struct rtx1_hreqst_message tx_hr_msg );      /* hdlcom1X.obj */
extern void tx_habort( void );

extern void symblg( bit operation, unsigned char sy_select );
extern void symblgchksm( bit operation, unsigned char sy_select );
extern void dis_allsymblg( void );

extern void ring( unsigned char note, unsigned char duration, unsigned char repetitions );

extern void fault( unsigned char proc_id, unsigned char fault_id, unsigned int  mess_id );

extern void exit_to_bl( void );
extern void exit_to_rst( void );
extern void pen_shut_down( void );
extern void reset_sys( void );

extern void retrig_psssd( void );
extern void stop_psssd( void );
extern void set_psssd_time( unsigned int psssd_time );

extern unsigned char ispechar( unsigned char tested_ch, unsigned char ch_specification );

extern unsigned char setcom( unsigned char baudrate, unsigned char parity, unsigned char databits );
extern void txchcom( char c );

extern unsigned char bankset( unsigned char );
extern void sv_currentbank( void );
extern void rp_previousbank( void );

extern void led( unsigned char color );
extern void beam( unsigned char on_off );
extern bit pen_portable( void );
extern bit battery_low( void );

extern void writeclock( struct time settingtime );
extern void readclock( struct time *destime );
extern bit clockiset( void );

extern void gotoxy( unsigned char column, unsigned char row );
extern void setFont(unsigned char fontType);
extern unsigned char getFont();
extern void scrollUp();
extern void scrollDown();	
extern void scrollEnable(unsigned char bEnable);
extern void ret_proc( void );
extern void printLabel(unsigned char *);

extern void kb_hreqst( struct kb_hreqst_message kb_hr_msg );
extern void kb_habort( void );

extern unsigned char ram_config( void );
extern void set_display_tab_offset(unsigned int offset);
extern unsigned char * terminal_name( void );

extern void icon_null( void ); 
extern void icon_bell(unsigned char on_off);
extern void icon_phone( unsigned char * );
extern void icon_tx( unsigned char * );	
extern void icon_mail(unsigned char on_off);
extern void icon_battery( unsigned char );
extern void icon_time( unsigned char * );
extern unsigned char contrast( unsigned char );

//externs for new Icon function
extern void icon_on(unsigned char, unsigned char);
extern void icon_off(unsigned char);

extern BOOL bt_rx2_ready ();
extern unsigned char bt_rx2_char();
extern void bt_tx2_char(unsigned char ch);
extern void bt_tx2_message( unsigned char * );
extern void bt_rx2_habort( void );
extern void bt_tx2_habort( void );
extern unsigned char bt_getcomerror( void );
extern bit enhanced_terminal( void );
extern no_autocall(void);

/********************** DOUBLE_SPEED prototype *******************/

extern unsigned char double_speed( unsigned char value );        // Dummy in 630 and 660,725,732,734 STANDARD TERMINALS.

/********************** SERIAL NUMBER prototype *******************/

extern unsigned char * serial_number( void );                    // Dummy in 660 or with EMPTYE2P.LIB

/********************** BACKLIGHT prototype ************************/

extern void backlight( unsigned char on_off );			 // Dummy in 630 and 732

/********************** RF prototype *******************************/

extern void ir_hreqst( struct ir_hreqst_message ir_hr_msg );     // Dummy in 660 or with EMPTYRF.LIB
extern void ir_habort( void );				         // Dummy in 660 or with EMPTYRF.LIB

/********************** E2PROM prototype ***************************/

extern void Usr_WriteE2prom( struct E2prom wr_strutt );          // Dummy in 660 or with E2PNOUSR.LIB and EMPTYE2P.LIB
extern void Usr_EraseE2prom( void );                             // Dummy in 660 or with E2PNOUSR.LIB and EMPTYE2P.LIB
extern unsigned char Usr_ReadE2prom( struct E2prom *rd_strutt ); // Dummy in 660 or with E2PNOUSR.LIB and EMPTYE2P.LIB

/********************** WAKEUP prototype ***************************/

extern void setwakeup( struct time settingtime, unsigned char settingtype ); // Dummy in 630 and 660 or with HDLCKNWU.LIB
extern unsigned char checkwakeup( void );				     // Dummy in 630 and 660 or with HDLCKNWU.LIB

/********************* MMC FS Externs *******************************/

extern void delay_ms( unsigned char );
extern void delay (unsigned int);

extern void Mmc_Pwr_Enable(void);
extern void Mmc_Pwr_Disable(void);


/********************* Bluetooth related functions *******************************/

extern void led(unsigned char) ;
extern void izcom( void );
extern void eicom(void);
extern void erxcom(void);

extern void Bt_Pwr_Enable();
extern void Bt_Pwr_Disable();

extern void bt_reset(void);
extern void bt_power(unsigned char);
extern BT_ERR bt_txATcmd(char *);
extern BT_ERR bt_setdefault(void);
extern BT_ERR bt_delete_bond_info(void);
extern BT_ERR bt_info(struct BT_INFO *btinfo);
	
extern BT_ERR bond(struct BT_CFG *bt_confg);
extern BT_ERR bt_open(void);
extern BT_ERR bt_close(void);
extern void led_bt(unsigned char);
extern BT_STATUS bt_status(void);
extern BT_ERR bt_init(struct BT_CFG *bt_confg);
extern BT_ERR bt_setcfg(struct BT_CFG *bt_confg,unsigned char bt_param_toset);
extern void bt_start(void);
extern void bt_stop(void);
extern void bttxedcom( void );

extern void rx2_hreqst();
extern void rx2_habort( void );
extern void tx2_hreqst( void *);
extern void tx2_habort( void );


//Bluetooth com handler function 
extern void bt_tx_hreqst( struct rtx_hreqst_message tx_hr_msg );
extern void bt_tx_habort( void );
extern void bt_rx_hreqst( struct rtx_hreqst_message rx_hr_msg );
extern void bt_rx_habort( void );
extern void setRts(unsigned char);
extern void setDtr(unsigned char);
extern unsigned char getDsr();
extern unsigned char getCts();
									
/********************* USB Mass Storage Externs *******************************/

extern void Usb_Pwr_Disable(void);
extern void Usb_Pwr_Enable(void);

extern unsigned char usb_open(unsigned char usb_profile);//handlers.
extern void usb_close(void);	//handlers.

extern unsigned char check_usbint(void);

/********************* USB Serial Emulation Storage Externs *******************************/
	 
extern BOOL usbser_rx_ready();
extern unsigned char usbser_rx_char();
extern BOOL usbser_tx_char(unsigned char);
extern BOOL usbser_tx_message(unsigned char*);

extern unsigned int crc_ccitt(unsigned char xdata *message, unsigned int length);

/********************* USB Keyboard Emulation Storage Externs *******************************/
extern unsigned char usbkbd_tx_message( char *usb_tx_hreqst_message );
extern unsigned char usbkbd_tx_char(unsigned char Key);
extern void set_keyboard_lang(unsigned char lang);
										
/********************** Device Insertion/Extraction event functions ***********/
extern void set_events(unsigned char ev);
extern unsigned char MMCSD_card_state();
extern unsigned char usb_cable_state();
extern unsigned char DCIN_cable_Insertion_State(); //NOW & BEFORE
extern unsigned char RS232_cable_Insertion_State();//NOW & BEFORE 
extern unsigned char USB_cable_Insertion_State();	 //NOW & BEFORE
extern unsigned char MMCSD_card_Insertion_State(); //NOW & BEFORE

extern unsigned char DCIN_cable_event(); //NOW
extern unsigned char RS232_cable_event();//NOW  
extern unsigned char USB_cable_event();  //NOW
extern unsigned char MMCSD_card_event(); //NOW

extern unsigned char DCIN_cable_extracted();
extern unsigned char USB_cable_extracted();
extern unsigned char RS232_cable_extracted();
extern unsigned char MMCSD_card_extracted();

void Insertion_info(INSERTION_INFO* dev_info);

extern void cable_insert_check(void);

//battery level constants:
extern unsigned char battery_warning(void);
extern void red_battery_level(unsigned char level);

//====== led function prototypes =============================================
extern void led_user(unsigned char );
extern void led_bt(unsigned char);